<#assign module="member"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/form.css">
</@override>
<@override name="body">

<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
		
			<div class="panel panel-default">
				<div class="panel-heading">
					客户：${passenger.name?if_exists}&nbsp;&nbsp;-&nbsp;&nbsp;${passenger.typeStr}
			    </div>
		    </div>
		
			<div class="panel panel-default margin-top">
				<div class="panel-heading">
					赠送优惠劵
			    </div>
			    <div class="panel-body">
    				<form id="submit_form" action="${ctx}/member/coupongift" class="form-horizontal" method="post">
		                <input type="hidden" id="id" name="id" value="${passenger.id}" />
		                <div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>选择优惠券：</label>
		                    <div class="col-sm-3">
			                    <select class="form-control" id="couponRuleId" name="couponRuleId" required>
			                    	<#list coupons as coupon>
		                    			<option value="${coupon.id}">${coupon.title?if_exists}</option>
									</#list>
			                    </select>
		                	</div>
		                </div>
						                
		                <div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>数量：</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control" id="amount" name="amount" type="number" value="1" min="1" max="10" required placeholder="输入需要赠送优惠劵的数量"/>
		                    	<span class="help-block">一次性最多赠送10张优惠劵。</span>
		                    </div>
		                </div>
    					
		                <div class="form-group" style="margin-left:10px;">
			                <label class="col-sm-3 control-label"></label>
			                <input id="submit_button" type="button" class="btn btn-primary" value="赠送">
			                <input type="button" class="btn btn-default" onclick="javascript:history.go(-1);" value="返回">
			            </div>
					</form>
        		</div>				
			</div>
			
		</div>
	</div>
</div>
</@override>
<@override name="footer">
<script type="text/javascript">
	$(document).ready(function(){
		
		$("#submit_button").click(function(){
			if(null==$("#couponRuleId").val()){
				$.scojs_message('请选择优惠券', $.scojs_message.TYPE_ERROR);
			    return false;
			}
		
			var amount=$("#amount").val();
			if(amount.length>0){
				var reg=/^(\d+)$/;
				if(!reg.test(amount)){
			       $.scojs_message('无效的数量！', $.scojs_message.TYPE_ERROR);
			       return false;
			    }
			    
			    if(amount>10){
			    	$.scojs_message('一次最多赠送10张优惠劵！', $.scojs_message.TYPE_ERROR);
			      	return false;
			    }
			
				var confirm = $.scojs_confirm({
		          content: "确认要赠送"+amount+"张优惠劵吗？",
		          action:function(){
		          	$("#submit_button").val("操作中...");
					$("#submit_button").attr("disabled",true);
		          	$("#submit_form").submit();
		          }
		        });
		        confirm.show();
			}
			else{
				$.scojs_message('请填写数量！', $.scojs_message.TYPE_ERROR);
			}
		});
		
	});
</script>
</@override>
<@extends name="../layout.ftl"/>